package invalidosgibusinesscomponentdependency;

import org.eclipse.emf.ecore.EObject;

import org.eclipse.viatra2.emf.incquery.validation.runtime.Constraint;
import org.eclipse.viatra2.emf.incquery.validation.runtime.ValidationUtil;
import org.eclipse.viatra2.emf.incquery.runtime.api.impl.BaseGeneratedMatcherFactory;
import invalidosgibusinesscomponentdependency.InvalidOSGiBusinessComponentDependencyMatch;
import invalidosgibusinesscomponentdependency.InvalidOSGiBusinessComponentDependencyMatcherFactory;
import invalidosgibusinesscomponentdependency.InvalidOSGiBusinessComponentDependencyMatcher;

public class InvalidOSGiBusinessComponentDependencyConstraint extends Constraint<InvalidOSGiBusinessComponentDependencyMatch> {

	private InvalidOSGiBusinessComponentDependencyMatcherFactory matcherFactory;

	public InvalidOSGiBusinessComponentDependencyConstraint() {
		matcherFactory = new InvalidOSGiBusinessComponentDependencyMatcherFactory();
	}

	@Override
	public String getMessage() {
		return "$osgiComponent.name$ OSGi business component should not depend from $otherComponent.name$ business component, cause it is implemented with another technology!";
	}

	@Override
	public EObject getLocationObject(InvalidOSGiBusinessComponentDependencyMatch signature) {
		Object location = signature.get("osgiComponent");
		if(location instanceof EObject){
			return (EObject) location;
		}
		return null;
	}
	
	@Override
	public int getSeverity() {
		return ValidationUtil.getSeverity("error");
	}
	
	@Override
	public BaseGeneratedMatcherFactory<InvalidOSGiBusinessComponentDependencyMatch, InvalidOSGiBusinessComponentDependencyMatcher> getMatcherFactory() {
		return matcherFactory;
	}
}
